package com.imageim.yimirror.common.ui;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.widget.Toast;

/**
 * 提示显示工具类
 * 
 * @author Administrator
 *
 */
public class PromptManager {

	private static ProgressDialog pd;

	private static Dialog loadingDialog;

	public static boolean DEBUG_TOAST = true;

	public static void setDebugToast(boolean debug) {
		DEBUG_TOAST = debug;
	}

	/**
	 * 推荐使用 带状态码的提示信息
	 * 
	 * @param context
	 * @param code
	 * @param msg
	 */
	public static void showToast(Context context, String code, String msg) {
		if (context != null) {
			if ("main".equalsIgnoreCase(Thread.currentThread().getName())) {
				Toast toast = null;
				if (DEBUG_TOAST) {
					toast = Toast.makeText(context, msg + "(" + code + ")",
							Toast.LENGTH_SHORT);
				} else {
					toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
				}
				toast.show();
			}
		}
	}

	/**
	 * Toast显示
	 * 
	 * @param context
	 * @param msg
	 */
	public static void showToast(Context context, String msg) {
		if (context != null) {
			if ("main".equalsIgnoreCase(Thread.currentThread().getName())) {
				Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
				// toast.setGravity(Gravity.BOTTOM, 0, 0);
				toast.show();
			} 
		}
	}

	/**
	 * 显示进度条
	 * 
	 * @param context
	 * @param msg
	 */
	public static void showProgress(Context context, String msg) {
		if (pd != null && pd.isShowing()) {
			pd.dismiss();
		}
		pd = new ProgressDialog(context);

		pd.setMessage(msg);

		pd.show();
	}

	/**
	 * 进度条移除
	 */
	public static void hideProgress() {
		if (pd != null && pd.isShowing()) {
			pd.dismiss();
		}
	}
 

	public static void hideLoadingDialog() {
		if (loadingDialog != null && loadingDialog.isShowing()) {
			loadingDialog.dismiss();
		}
	}

 

}
